<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">&lt;?php
<span id='global-property-'>/**
</span> * Cube PHP Framework
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the &quot;License&quot;); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * @author Dillen / Steffen
 */

namespace Library\Mvc;
 
<span id='Library-Mvc-Bootstrap'>/**
</span> * @class Library.Mvc.Bootstrap 
 * 
 * Library.Mvc.Bootstrap is the application bootstrap class, which runs your actual application.
 */
class Bootstrap
{
<span id='Library-Mvc-Bootstrap-property-application'>	/**
</span>	 * Application
	 * 
	 * @property {Library.Application} application
	 * @var \Library\Application
	 */
	public $application;
	
<span id='Library-Mvc-Bootstrap-property-request'>	/**
</span>	 * Request
	 * 
	 * @property {Library.Mvc.Request} request
	 * @var \Library\Mvc\Request
	 */
	public $request;
	
<span id='Library-Mvc-Bootstrap-property-router'>	/**
</span>	 * Router
	 * 
	 * @property {Library.Mvc.Router} router
	 * @var \Library\Mvc\Router
	 */
	public $router;
	
<span id='Library-Mvc-Bootstrap-property-events'>	/**
</span>	 * EventManager
	 * 
	 * @property {Library.Mvc.EventManager} events
	 * @var \Library\Mvc\EventManager
	 */
	public $events;
	
<span id='Library-Mvc-Bootstrap-method-__construct'>	/**
</span>	 * Constructor
	 * 
	 * @method __construct
	 * @param {Library.Application} $application
	 */
	public function __construct(\Library\Application $application)
	{
		//Set error handler
		$error = new \Library\Error($application-&gt;config, $this);
		
		set_exception_handler(array($error, 'displayException'));
		
		$this-&gt;application = $application;
		$this-&gt;events = new Event\Manager($this-&gt;application-&gt;config);
		
		$this-&gt;_routerDispatch();
	}
	
<span id='Library-Mvc-Bootstrap-method-_routerDispatch'>	/**
</span>	 * Router dispatch event
	 * 
	 * @method _routerDispatch
	 * @private
	 */
	final private function _routerDispatch()
	{
		$this-&gt;request = new \Library\Mvc\Request();
		
		$this-&gt;router = new \Library\Mvc\Router($this-&gt;request);
		$this-&gt;router-&gt;application = $this-&gt;application;
		
		$this-&gt;__routerPreDispatch($this-&gt;request);
		
		// Instantiate the controller
		$controller = $this-&gt;router-&gt;prepare();
	
		//Inject needed classes
		$controller-&gt;events = $this-&gt;events;
		
		//Call constroller constructor
		$controller-&gt;__init();
		
		$this-&gt;router-&gt;dispatch();
		
		$this-&gt;__routerDispatch($this-&gt;request, $this-&gt;router);
		
		if ($this-&gt;application-&gt;config['layout']['auto_render'] == true)
		{
			$controller-&gt;layout-&gt;renderLayout();
		}
	}
	
<span id='Library-Mvc-Bootstrap-method-__applicationpreInit'>	/**
</span>	 * Application pre-init event
	 * 
	 * @method __applicationpreInit
	 */
	protected function __applicationPreInit()
	{
		
	}
	
	protected function __applicationInit()
	{
		
	}
	
	protected function __applicationError($exception)
	{
		
	}
	
	protected function __routerPredispatch(&amp;$request)
	{
		
	}
	
	protected function __routerDispatch(&amp;$request, &amp;$router)
	{
		
	}
	
<span id='Library-Mvc-Bootstrap-method-callEvent'>	/**
</span>	 * Call a bootstrap event
	 * 
	 * @param String $event
	 * @param Array $args
	 * @method callEvent
	 */
	public function callEvent($event, $args)
	{
		return count($args) &gt; 0 ? call_user_func_array(array($this, '__' . $event), $args) : $this-&gt;{'__' . $event};
	}
}</pre>
</body>
</html>
